From 07bb349018b93e65e5591d8825629aa37ba0e02a Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 23 Nov 2006 09:36:48 +0000 Subject: [PATCH] [SVM] Make sure that the WP bit is always set in CR0 when running SVM guests. This is necessary to be sure that the shadow mode code can always detect writes to guest page tables. This should fix Windows restore from hibernation on SVM platforms. Signed-off-by: Tom Woller --- xen/arch/x86/hvm/svm/svm.c | 4 ++-- xen/arch/x86/hvm/svm/vmcb.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 455bdac52e..f2a8659136 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1441,7 +1441,7 @@ static int svm_set_cr0(unsigned long value) /* We don't want to lose PG. ET is reserved and should be always be 1*/ paging_enabled = svm_paging_enabled(v); value |= X86_CR0_ET; - vmcb->cr0 = value | X86_CR0_PG; + vmcb->cr0 = value | X86_CR0_PG | X86_CR0_WP; v->arch.hvm_svm.cpu_shadow_cr0 = value; /* TS cleared? Then initialise FPU now. */ @@ -2094,7 +2094,7 @@ static int svm_do_vmmcall_reset_to_realmode(struct vcpu *v, vmcb->tsc_offset = 0; /* VMCB State */ - vmcb->cr0 = X86_CR0_ET | X86_CR0_PG; + vmcb->cr0 = X86_CR0_ET | X86_CR0_PG | X86_CR0_WP; v->arch.hvm_svm.cpu_shadow_cr0 = X86_CR0_ET; vmcb->cr2 = 0; diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c index fb246ae0ad..f00372440e 100644 --- a/xen/arch/x86/hvm/svm/vmcb.c +++ b/xen/arch/x86/hvm/svm/vmcb.c @@ -197,6 +197,7 @@ static int construct_vmcb(struct vcpu *v) /* Guest CR0. */ vmcb->cr0 = read_cr0(); arch_svm->cpu_shadow_cr0 = vmcb->cr0 & ~(X86_CR0_PG | X86_CR0_TS); + vmcb->cr0 |= X86_CR0_WP; /* Guest CR4. */ arch_svm->cpu_shadow_cr4 = -- 2.30.2